#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
int isPrime(int x);
int main()
{
	int years, months, days, add=0;
	scanf("%d,%d", &years,&months);
	add = (years % 4 == 0 && years % 100 != 0 || years % 400 == 0) ? 1 : 0;
	switch (months)
	{
		case 1:
		{
			days = 31;
			break;
		}
		case 2:
		{
			days = 28 + add;
			break;
		}
		case 3:
		{
			days = 31;
			break;
		}
		case 4:
		{
			days = 30;
			break;
		}
		case 5:
		{
			days = 31;
			break;
		}
		case 6:
		{
			days = 30;
			break;
		}
		case 7:
		{
			days = 31;
			break;
		}
		case 8:
		{
			days = 31;
			break;
		}
		case 9:
		{
			days = 30;
			break;
		}
		case 10:
		{
			days = 31;
			break;
		}
		case 11:
		{
			days = 30;
			break;
		}
		case 12:
		{
			days = 31;
			break;
		}
	}
	printf("%d", days);
	return 0;
}

